package com.kh.first.controller;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.kh.first.config.WxCpConfiguration;
import com.kh.first.pojo.*;
import com.kh.first.pojo.common.*;

import com.kh.first.service.DepartmentService;
import com.kh.first.service.RepairLogService;
import com.kh.first.service.SettingService;
import com.kh.first.utils.Tools;
import com.kh.first.utils.UserUtils;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpOAuth2Service;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.api.WxCpUserService;
import me.chanjar.weixin.cp.bean.WxCpDepart;
import me.chanjar.weixin.cp.bean.WxCpUser;
import me.chanjar.weixin.cp.bean.WxCpXmlMessage;
import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage;
import me.chanjar.weixin.cp.util.crypto.WxCpCryptUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@Controller
@RequestMapping("repairLogController")
public class RepairLogController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    static final String currentFolder = UserUtils.THEME + "repairlog/";
    @Autowired
    private RepairLogService repairLogService;
    @Autowired
    SettingService settingService;

    @Autowired
    DepartmentService departmentService;

    @RequestMapping(params = "goRepairLogList")
    public String goRepairLogList() {
        return currentFolder + "repairlog-list";
    }

    @RequestMapping(params = "home")
    public String home() {
        return UserUtils.THEME + "home";
    }

    @RequestMapping(params = "goTotalDepartment")
    public String goTotalDepartment() {
        return currentFolder + "total-department";
    }

    @RequestMapping(params = "goTotalRepairStaff")
    public String goTotalRepairStaff() {
        return currentFolder + "total-repair-staff";
    }

    @RequestMapping(params = "goCommonDateQuery")
    public String goCommonDateQuery() {
        return currentFolder + "common-date-query";
    }

    @RequestMapping(params = "goChart")
    public String goChart(Model model) {

        return currentFolder + "chart";
    }

    private WxCpXmlOutMessage route(Integer agentId, WxCpXmlMessage message) {
        try {
            return WxCpConfiguration.getRouters().get(agentId).route(message);
        } catch (Exception e) {
            this.logger.error(e.getMessage(), e);
        }

        return null;
    }

    @GetMapping(produces = "text/plain;charset=utf-8", value = "wx/{agentId}")
    @ResponseBody
    public String authGet(@PathVariable Integer agentId, //
                          @RequestParam(name = "msg_signature", required = false) String signature,
                          @RequestParam(name = "timestamp", required = false) String timestamp,
                          @RequestParam(name = "nonce", required = false) String nonce,
                          @RequestParam(name = "echostr", required = false) String echostr) {
        this.logger.info("\n接收到来自微信服务器的认证消息：signature = [{}], timestamp = [{}], nonce = [{}], echostr = [{}]",
                signature, timestamp, nonce, echostr);

        if (StringUtils.isAnyBlank(signature, timestamp, nonce, echostr)) {
            throw new IllegalArgumentException("请求参数非法，请核实!");
        }
//		Integer agentId = Tools.appConfig.getAgentId();
        final WxCpService wxCpService = WxCpConfiguration.getCpService(agentId);
        if (wxCpService == null) {
            throw new IllegalArgumentException(String.format("未找到对应agentId=[%d]的配置，请核实！", agentId));
        }
//        http://s8fzrz.natappfree.cc/repairLogController/wx.do
//        http://hr.khmm.com.cn/repairLogController/wx.do
        if (wxCpService.checkSignature(signature, timestamp, nonce, echostr)) {
            String decrypt = new WxCpCryptUtil(wxCpService.getWxCpConfigStorage()).decrypt(echostr);
            return decrypt;
        }

        return "非法请求";
    }

    @PostMapping(produces = "application/xml; charset=UTF-8", value = "wx/{agentId}")
    @ResponseBody
    public String post(@PathVariable Integer agentId, //
                       @RequestBody String requestBody, @RequestParam("msg_signature") String signature,
                       @RequestParam("timestamp") String timestamp, @RequestParam("nonce") String nonce) {
        this.logger.info("\n接收微信请求：[signature=[{}], timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ", signature,
                timestamp, nonce, requestBody);

//		Integer agentId = Tools.appConfig.getAgentId();
        final WxCpService wxCpService = WxCpConfiguration.getCpService(agentId);
        WxCpXmlMessage inMessage = WxCpXmlMessage.fromEncryptedXml(requestBody, wxCpService.getWxCpConfigStorage(),
                timestamp, nonce, signature);
//        this.logger.debug("\n消息解密后内容为：\n{} ", JsonUtils.toJson(inMessage));
        WxCpXmlOutMessage outMessage = this.route(agentId, inMessage);
        if (outMessage == null) {
            return "";
        }

        String out = outMessage.toEncryptedXml(wxCpService.getWxCpConfigStorage());
        this.logger.debug("\n组装回复信息：{}", out);
        return out;
    }

    public static final String splitChar = "kehuaHodings";

    @RequestMapping("login")
    public String login(Integer agentId, //
                        @RequestParam(required = false, defaultValue = "index") String state) {
//		Integer agentId = Tools.appConfig.getAgentId();
        final WxCpService wxCpService = WxCpConfiguration.getCpService(agentId);
        state = state.replace("-", "/");
        String urlResult = wxCpService.getOauth2Service()
                .buildAuthorizationUrl(doMain + "/repairLogController/setName.do", state + splitChar + agentId);

        return "redirect:" + urlResult;
    }

    @Value("${url.domain}")
    String doMain;

//    public String getRepairUserRole() {
//
//    }

    @RequestMapping("setName")
    public String setName(String code, String state, HttpServletRequest request) throws WxErrorException, IOException {
        String[] arr = state.split(splitChar);
        String stateStr = arr[0];
//        new Thread(() -> {
//            try {
        Integer agentId = Integer.valueOf(arr[1]);// Tools.appConfig.getAgentId();
        final WxCpService wxCpService = WxCpConfiguration.getCpService(agentId);
        WxCpOAuth2Service oauth2Service = wxCpService.getOauth2Service();
        String[] res = oauth2Service.getUserInfo(code);
        WxCpUserService userService = wxCpService.getUserService();
        String userId = res[0];
        System.out.println("-----------------------------------start");
        String result =
                wxCpService.get(
                        "https://qyapi.weixin.qq.com/cgi-bin/user/get",
                        String.format("access_token=%s&userid=%s",
                                wxCpService.getAccessToken(), userId)
                );
        ObjectMapper objectMapper = new ObjectMapper();
        WxUser wxUser = objectMapper.readValue(result, WxUser.class);
        String deviceId = res[1];
        WxCpUser user = userService.getById(userId);
        Long[] departIds = user.getDepartIds();
        String usedId = wxUser.getAlias();
        usedId = wxUser.getUserid();
        UserUtils.setUserPinYin(usedId, request);
        UserUtils.setAdminStatus(departIds, request);
        UserUtils.setUserName(user.getName(), request);
//            } catch (JsonParseException e) {
//                e.printStackTrace();
//            } catch (IOException e) {
//                e.printStackTrace();
//            } catch (WxErrorException e) {
//                e.printStackTrace();
//            }
//        }).start();
        System.out.println("-----------------------------------end");
        System.out.println(stateStr);
        return String.format("redirect:%s/%s.html", doMain, stateStr);
    }

    @RequestMapping(params = "makeLineChart")
    @ResponseBody
    public Map<String, Object> makeLineChart() {
        String year = Tools.getYear();
        int thisYearInt = Integer.valueOf(year);
        List<Map<String, Object>> lineChartThisYear = repairLogService.getYearLine(thisYearInt);
        Integer lastYear = thisYearInt - 1;
        List<Map<String, Object>> lineChartLastYear = repairLogService.getYearLine(lastYear);
        Map<String, Object> map = new HashMap<>();
        map.put("thisYear", year);
        map.put("thisYearData", lineChartThisYear);
        map.put("lastYear", lastYear);
        map.put("lastYearData", lineChartLastYear);
        map.put("code", 1);
        return map;
    }

    @RequestMapping(params = "goTotalRepairLogType")
    public String goTotalRepairLogType() {
        return currentFolder + "total-repair-log-type";
    }

    @RequestMapping(params = "dataGridTotalRepairStaff")
    @ResponseBody
    public LayTableJson<RepairStaffTotalPojo> dataGridTotalRepairStaff(RepairLogPojo pojo, PageParam pageParam)
            throws ParseException {
        LayTableJson<RepairStaffTotalPojo> ajaxJson = new LayTableJson<>();
        int limit = pageParam.getLimit();
        int page = pageParam.getPage();
//        int size = limit == 0 ? 10 : limit;
//        pojo.setStart(page == 0 ? 0 : (page - 1) * size);
//        pojo.setSize(size);
        if (null == pojo.getApplyTimeStart()) {
            SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date start = simpleDateFormat1
                    .parse(String.format("%s-%s-01 00:00:00", UserUtils.getYear(), UserUtils.getMonth()));
            Date end = simpleDateFormat1.parse(String.format("%s-%s-%s 23:59:00", UserUtils.getYear(),
                    UserUtils.getMonth(), UserUtils.getDateMax()));
            pojo.setApplyTimeStart(start);
            pojo.setApplyTimeEnd(end);
        }
        List<SettingPojo> settingList = settingService.getSettingList(null);
        List<RepairStaffTotalPojo> list = new ArrayList<>();
        for (SettingPojo settingPojo : settingList) {
            String name = settingPojo.getName();
            pojo.setRepairStaffName(name);
            List<RepairLogPojo> repairLogList = repairLogService.getRepairLogList(pojo);
            RepairStaffTotalPojo totalPojo = new RepairStaffTotalPojo();
            totalPojo.setName(name);
            totalPojo.setCount(repairLogList.size());
            list.add(totalPojo);
        }

        pojo.setRepairStaffName(",");
        List<RepairLogPojo> repairLogList = repairLogService.getRepairLogList(pojo);
        RepairStaffTotalPojo totalPojo = new RepairStaffTotalPojo();
        totalPojo.setName("共同维护");
        totalPojo.setCount(repairLogList.size());
        list.add(totalPojo);

        pojo.setRepairStaffName(null);
        List<RepairLogPojo> repairLogListTotal = repairLogService.getRepairLogList(pojo);

        RepairStaffTotalPojo totalPojo2 = new RepairStaffTotalPojo();
        totalPojo2.setName("合计");
        totalPojo2.setCount(repairLogListTotal.size());
        list.add(totalPojo2);
        ajaxJson.data = list;
        ajaxJson.count = list.size();
        return ajaxJson;
    }

    @RequestMapping(params = "dataGridTotalDepartment")
    @ResponseBody
    public LayTableJson<DepartmentTotalPojo> dataGridTotalDepartment(DepartmentTotalPojo pojo, PageParam pageParam)
            throws ParseException {
        LayTableJson<DepartmentTotalPojo> ajaxJson = new LayTableJson<>();
        int limit = pageParam.getLimit();
        int page = pageParam.getPage();
        int size = limit == 0 ? 10 : limit;
        pojo.setStart(page == 0 ? 0 : (page - 1) * size);

        pojo.setSize(size);
        if (null == pojo.getApplyTimeStart()) {
            SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date start = simpleDateFormat1
                    .parse(String.format("%s-%s-01 00:00:00", UserUtils.getYear(), UserUtils.getMonth()));
            Date end = simpleDateFormat1.parse(String.format("%s-%s-%s 23:59:00", UserUtils.getYear(),
                    UserUtils.getMonth(), UserUtils.getDateMax()));
            pojo.setApplyTimeStart(start);
            pojo.setApplyTimeEnd(end);
        }
        List<DepartmentTotalPojo> repairGroupByDepartmentList = repairLogService.getRepairGroupByDepartment(pojo);
        Long count = repairLogService.countRepairGroupByDepartment(pojo);
        ajaxJson.data = repairGroupByDepartmentList;
        ajaxJson.count = count.intValue();
        return ajaxJson;
    }

    @RequestMapping(params = "dataGridTotalRepairType")
    @ResponseBody
    public LayTableJson<RepairStaffTotalPojo> dataGridTotalRepairType(RepairStaffTotalPojo pojo, PageParam pageParam)
            throws ParseException {
        LayTableJson<RepairStaffTotalPojo> ajaxJson = new LayTableJson<>();
        int limit = pageParam.getLimit();
        int page = pageParam.getPage();
        int size = limit == 0 ? 10 : limit;
        pojo.setStart(page == 0 ? 0 : (page - 1) * size);
        pojo.setSize(size);
        if (null == pojo.getApplyTimeStart()) {
            SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date start = simpleDateFormat1
                    .parse(String.format("%s-%s-01 00:00:00", UserUtils.getYear(), UserUtils.getMonth()));
            Date end = simpleDateFormat1.parse(String.format("%s-%s-%s 23:59:00", UserUtils.getYear(),
                    UserUtils.getMonth(), UserUtils.getDateMax()));
            pojo.setApplyTimeStart(start);
            pojo.setApplyTimeEnd(end);
        }
        List<RepairStaffTotalPojo> repairGroupByDepartmentList = repairLogService.getRepairLogGroupByRepairType(pojo);
        ajaxJson.data = repairGroupByDepartmentList;
        ajaxJson.count = repairGroupByDepartmentList.size();
        return ajaxJson;
    }

    @RequestMapping(params = "dataGrid")
    @ResponseBody // repairLogController.do?dataGrid
    public LayTableJson<RepairLogPojo> dataGrid(RepairLogPojo pojo, PageParam pageParam) throws ParseException {
        LayTableJson<RepairLogPojo> ajaxJson = new LayTableJson<>();
        int limit = pageParam.getLimit();
        int page = pageParam.getPage();
        int size = limit == 0 ? 10 : limit;
        pojo.setStart(page == 0 ? 0 : (page - 1) * size);
        pojo.setSize(size);
        if (null == pojo.getApplyTimeStart()) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date start = simpleDateFormat
                    .parse(String.format("%s-%s-01 00:00:00", UserUtils.getYear(), UserUtils.getMonth()));
            Date end = simpleDateFormat.parse(String.format("%s-%s-%s 23:59:00", UserUtils.getYear(),
                    UserUtils.getMonth(), UserUtils.getDateMax()));
            pojo.setApplyTimeStart(start);
            pojo.setApplyTimeEnd(end);
        }
        int mobile = pojo.getMobile();
        if (-1 != mobile) {
            pojo.setRecordUserId(UserUtils.getUserPinYin());
        }

        if (!pojo.isPc()) {
            Integer logStatus = pojo.getLogStatus();
            if (null != logStatus && -1 == logStatus) {// 未接单
                pojo.setLogStatus(null);// -1 不是要看全部的，看的就是未接单1的
            } else if (logStatus == 3 || logStatus == 2) {// 已经接单，并且是管理员
                Boolean adminStatus = UserUtils.getAdminStatus();
                if (true == adminStatus) {
                    pojo.setReceiveStaffId(UserUtils.getUserPinYin());
                }
            }
        }
        List<RepairLogPojo> RepairLogList = repairLogService.getRepairLogList(pojo);
        ajaxJson.data = RepairLogList;
        ajaxJson.count = repairLogService.countRepairLogList(pojo).intValue();
        return ajaxJson;
    }

    @RequestMapping("admin")
    public String admin() {
        return "admin";
    }

    @RequestMapping(params = "adjustAdmin")
    @ResponseBody
    public AjaxJson<String> adjustAdmin() {
        AjaxJson<String> ajaxJson = new AjaxJson<>();
        if (!UserUtils.getAdminStatus()) {
            ajaxJson.code = AjaxJson.error;
        }
        return ajaxJson;
    }

    @RequestMapping("hhh")
    @ResponseBody
    public String hhh() {
        return "hhhhh";
    }

    @RequestMapping(params = "goRepairLogAdd")
    public String goRepairLogAdd(Model model) {
        RepairLogPojo pojo = new RepairLogPojo();
        pojo.setRepairType(1);
        SettingPojo settingPojo = new SettingPojo();
        settingPojo.setMGroup("repairName");
        List<SettingPojo> settingList = settingService.getSettingList(settingPojo);
        Map<String, Object> map = new HashMap<>();
        map.put("update", 0);
        map.put("names", settingList);
        model.addAttribute("setting", map);
        List<DepartmentPojo> departmentList = departmentService.getDepartmentList(null);
        model.addAttribute("departmentList", departmentList);
        pojo.setSolveWay("无");
        pojo.setCostMoney(0L);
        pojo.setId(0L);// 想吐了
        model.addAttribute("repairlog", pojo);
        return currentFolder + "repairlog-add-update";
    }

    @RequestMapping(params = "goRepairLogQuery")
    public String goRepairLogQuery(Model model, RepairLogPojo pojo) {
        model.addAttribute("repairlog", pojo);
        return currentFolder + "repairlog-query";
    }

    @RequestMapping(params = "goRepairLogUpdate")
    public String goRepairLogUpdate(RepairLogPojo repairlog, Model model) {
        repairlog = repairLogService.getRepairLogById(repairlog);
//        repairlog = RepairLogList.get(0);//报错让他报
        Map<String, Object> map = new HashMap<>();
        map.put("update", 1);
        model.addAttribute("setting", map);
        List<DepartmentPojo> departmentList = departmentService.getDepartmentList(null);
        model.addAttribute("departmentList", departmentList);
        model.addAttribute("repairlog", repairlog);
        return currentFolder + "repairlog-add-update";
    }

    @RequestMapping(params = "setGet")
    @ResponseBody
    public AjaxJson<SettingPojo> setGet() {
        AjaxJson<SettingPojo> ajaxJson = new AjaxJson<>();
        List<SettingPojo> list = new ArrayList<>();
        for (long i = 0; i < 100; i++) {
            SettingPojo settingPojo = new SettingPojo();
            settingPojo.setName("张三" + i);
            settingPojo.setId(i + 1);
            list.add(settingPojo);
        }
        ajaxJson.list = list;
        return ajaxJson;
    }

    @RequestMapping(params = "doRepairLogAdd")
    @ResponseBody // url 调试
    public AjaxJson<String> doRepairLogAdd(RepairLogPojo repairlog, WxParams wxParams, HttpServletRequest request) throws WxErrorException {
        AjaxJson<String> ajaxJson = new AjaxJson<>();
        int mobile = repairlog.getMobile();
        if (-1 != wxParams.getWxSet()) {
            UserUtils.setUserPinYin(wxParams.getWxUserName(), request);
        }
        String userPinYin = UserUtils.getUserPinYin();
        if (StringUtils.isBlank(userPinYin)) {
            ajaxJson.code = AjaxJson.error;
            ajaxJson.data = "有问题，联系管理员";
            return ajaxJson;
        }
        if (-1 == mobile) {
            List<String> repairStaffNameList = repairlog.getRepairStaffNameList();
            repairlog.setRepairStaffName(getNames(repairStaffNameList));
        } else {
            // 来自手机的请求
            repairlog.setApplyTime(new Date());
            Integer agentId = 1000004;// Tools.appConfig.getAgentId();
            final WxCpService wxCpService = WxCpConfiguration.getCpService(agentId);
            // 把名字捞出来
            WxCpUser user = wxCpService.getUserService().getById(userPinYin);
            String name = user.getName();
            Long[] departIds = user.getDepartIds();
            String departments = "";
            for (Long departId : departIds) {
                List<WxCpDepart> list = wxCpService.getDepartmentService().list(departId);
                WxCpDepart wxCpDepart = list.get(0);
                departments = wxCpDepart.getName() + ",";
            }
            repairlog.setApplyStaffDepartment(departments);
            repairlog.setApplyStaffName(name);
            logger.info("departments:{}", departments);
        }
        repairlog.setRecordUserId(userPinYin);
        repairlog.setId(null);
        repairLogService.saveRepairLog(repairlog);
        return ajaxJson;
    }
//    static void getDepFullPath(WxCpDepart wxCpDepart){
//        Long id = wxCpDepart.getId();
//        if(1!=id){
//            getDepFullPath();
//        }
//    }

    String getNames(List<String> repairStaffNameList) {
        List<String> joinList = new ArrayList<>();
        for (String name : repairStaffNameList) {
            if (null != name) {
                joinList.add(name);
            }
        }
        return StringUtils.join(joinList, ",");
    }

    @RequestMapping(params = "doRepairLogUpdate")
    @ResponseBody
    public AjaxJson<String> doRepairLogUpdate(RepairLogPojo repairlog) throws WxErrorException {
        AjaxJson<String> ajaxJson = new AjaxJson<>();
//        List<String> repairStaffNameList = repairlog.getRepairStaffNameList();
//        repairlog.setRepairStaffName(getNames(repairStaffNameList));
        int logStatus = repairlog.getLogStatus();
        if (2 == logStatus) {
            repairlog.setReceiveStaffId(UserUtils.getUserPinYin());
            repairlog.setReceiveStaffName(UserUtils.getUserName());
            repairlog.setReceiveTime(new Date());
        }
        if (3 == logStatus) {
            repairlog.setRepairCompleteTime(new Date());
        }
        repairLogService.updateRepairLogById(repairlog);
        return ajaxJson;
    }

    @RequestMapping(params = "isNotRepair")
    @ResponseBody
    public AjaxJson isNotRepair(RepairLogPojo repairLogPojo) {
        AjaxJson<String> ajaxJson = new AjaxJson<>();
        repairLogPojo = repairLogService.getRepairLogById(repairLogPojo);
        int logStatus = repairLogPojo.getLogStatus();
        if (1 != logStatus) {
            ajaxJson.code = AjaxJson.error;
        }
        return ajaxJson;
    }

    @RequestMapping(params = "canRate")
    @ResponseBody
    public AjaxJson canRate(RepairLogPojo repairLogPojo) {
        AjaxJson<String> ajaxJson = new AjaxJson<>();
        repairLogPojo = repairLogService.getRepairLogById(repairLogPojo);
        int logStatus = repairLogPojo.getLogStatus();
        if (3 != logStatus) {
            ajaxJson.code = AjaxJson.error;
        }
        return ajaxJson;
    }

    @RequestMapping(params = "echart")
    @ResponseBody
    public AjaxJson echart(RepairLogPojo repairLogPojo) {
        AjaxJson<PipeChartPojo> ajaxJson = new AjaxJson<>();
        ajaxJson.list = repairLogService.findMesTypeCount(repairLogPojo);
        return ajaxJson;
    }

    // curl http://localhost:8883/repair/repairLogController/uploadFile.do -X POST
    // -F "file=@UpController.java"
//    curl http://localhost:8883/repairLogController/uploadFile.do -X POST -F "file=@UpController.java"
//    curl http://localhost/repairLogController/uploadFile.do -X POST -F "file=@UpController.java"
    @Value("${upload.image.path}")
    String imagePath;

    @PostMapping("/uploadFile")
    @ResponseBody
    public AjaxJson<String> uploadFile(@RequestParam("file") MultipartFile file) throws IOException {
        AjaxJson<String> ajaxJson = new AjaxJson<>();
        String originalFilename = file.getOriginalFilename();
        String uuid = UUID.randomUUID().toString().replace("-", "");
        String savedFileName = uuid + originalFilename;
//        System.out.println(imagePath);
        String pathname = imagePath + File.separator + savedFileName;

        file.transferTo(new File(pathname));
        ajaxJson.data = savedFileName;
        return ajaxJson;
    }

    class Student{
        String name;
    }
    class Teacher{
        String age;
        String name;
    }
    public void newInstance() {
        List<Student> list = new ArrayList<>();
        Student s=new Student();
        s.name = "张三";
        list.add(s);
        print(list);
    }

    public void print(Object object) {
//        get name
        // get age
    }

}
